package com.itheima.dubbo.service;

import com.itheima.dubbo.UserInterface;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerProperties;

import java.util.Random;
import java.util.stream.IntStream;


@DubboService(
        weight = 1,//权重
        version = "1.0.1", //版本设置，用于灰度发布
        timeout = 2000, //生产者 接口级别设置超时时间2000 优先级中等 低于同等级消费者
        methods = {@Method(
                name = "hello",
                timeout = 1800, // 生产者 方法级别设置超时时间为1800 优先级最高，低于同等级消费者设置
                retries = 3
        )}

)
public class UserInterfaceImpl implements UserInterface {


    @Override
    public String hello(String name) {
        Object password = RpcContext.getContext().getObjectAttachment("password"); //获取非String类型隐式传参
        Object user = RpcContext.getContext().getObjectAttachment("user"); //获取非String类型隐式传参
        String password1 = RpcContext.getContext().getAttachment("password"); //获取String类型隐式传参
        System.out.println("password = " + password);
        System.out.println("password1 = " + password1);
        System.out.println("user = " + user.toString());
        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        return name;
    }
}
